package com.springboot.vo;

import lombok.Data;
import org.springframework.data.domain.Page;

/**
 * @author: lzh
 */
@Data
public class PageVO {

    Integer pageNumber;

    Integer pageSize;

    Integer totalElements;

    Integer totalPages;

    Object content;

    private PageVO(){};

    public static PageVO convert(Page page) {
        PageVO pageVO = new PageVO();
        pageVO.pageNumber = page.getNumber() + 1;
        pageVO.pageSize = page.getSize();
        pageVO.totalElements = Math.toIntExact(page.getTotalElements());
        pageVO.totalPages = page.getTotalPages();
        pageVO.content = page.getContent();
        return pageVO;
    }

}
